//
//  CCSClient.h
//  ivcs_ios_demo
//
//  Created by zealcomm user on 2020/10/22.
//  Copyright © 2020 zealcomm user. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CallBackObject.h"
#import "Constant.h"
#import <SocketIO/SocketIO-Swift.h>
@protocol CCSClientDelegate <NSObject>

@optional

/// ccs socketIo相关的错误回调
/// @param code 错误code
/// @param message message
-(void)ccsErrorWithCode:(IVCSSDKErrorCode)code andMessage:(NSString *_Nullable)message;

/// 呼叫坐席的进度回调
/// @param progress 进度的状态信息
-(void)requestSessionProgress:(NSDictionary *_Nonnull)progress;

/// 用户被drop
/// @param message 原因信息
-(void)onDrop:(NSDictionary *_Nonnull)message;

/// 用户加入session
/// @param personInfo 用户信息
-(void)onJoinSession:(NSDictionary *_Nonnull)personInfo;

/// 用户离开session
/// @param personInfo 用户信息
-(void)onQuitSession:(NSDictionary *_Nonnull)personInfo;

/// 坐席音视频准备就绪
-(void)agentVideoReadyToTalk;

/// 正在转接其他坐席
-(void)onHoldOn;

/// 坐席推送采集信息引导框，移动端可根据指令渲染一个拍照引导框
-(void)onPhotoGuideBox;

/// 坐席截取访客画面
-(void)onScreenSnapshotRequest;

/// 坐席邀请访客手写签名
-(void)onHandSignatureRequest;

/// 收到自定义消息
/// @param message 消息
-(void)onCustomMessage:(id _Nullable )message;

/// 收到表单信息
/// @param data 消息
-(void)onFormData:(id _Nullable )data;


/// 收到文本消息
/// @param message 文本消息
-(void)onTextMessage:(id _Nullable)message;


/// 收到资源文件
/// @param data 数据
-(void)OnResourceData:(id _Nullable)data;

@end


//@import SocketIO;
NS_ASSUME_NONNULL_BEGIN

typedef void (^_Nonnull completeBlock)(CallBackObject*_Nonnull);

@interface CCSClient : NSObject

@property (nonatomic,weak) id<CCSClientDelegate>delegate;

/// socektIOClient
@property(strong,nonatomic)SocketIOClient *socket;

/// session room Token
@property(strong,nonatomic)NSString *roomtoken;

/// session participants list
@property(strong,nonatomic)NSMutableArray *userList;

/// connect ccs socketio
/// @param ccsUrl url
/// @param token access token
/// @param complete callback
-(void)connectWithUrl:(nonnull NSString *)ccsUrl andToken:(nonnull NSString *)token complete:(completeBlock)complete;


/// 发起视频呼叫
/// @param requestParameter 呼叫参数
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)requestSession:(nonnull NSDictionary *)requestParameter
        onSuccess:(void (^)(NSDictionary *result))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

/// ccsclient is valid
/// @param client ccsClient object
+(void)validateCcsClient:(CCSClient *)client
                 onSuccess:(void (^)(void))onSuccess
                 onFailure:(void (^)(NSError *error))onFailure;

/// 退出会话
/// @param parameter 默认为空
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)quitSession:(_Nullable id)parameter
                onSuccess:(void (^)(void))onSuccess
                onFailure:(void (^)(NSError *error))onFailure;



/// 分享url资源文件给对方
/// @param type 资源类型 ['doc','pic','video','aduio','page','paper']
/// @param url 资源地址
/// @param name 资源名字
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type
                 resourceUrl:(NSString *)url
                 resourceName:(NSString *)name
                 toRoles:(NSString *)roles
                 onSuccess:(void (^)(void))onSuccess
                 onFailure:(void (^)(NSError *error))onFailure;




/// 分享资源文件
/// @param type 文件类型  ['doc','pic','video','aduio','page','paper']
/// @param uploadUrl 上传的url
/// @param fileData fileData
/// @param fileName 文件名
/// @param mimeType 文件类型
/// @param roles 发送给对方的角色 默认是agents
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)shareResourceWithType:(NSString *)type
            uploadUrl:(NSString *)uploadUrl
            fileData:(NSData *)fileData
            fileName:(NSString *)fileName
            mimeType:(NSString *)mimeType
            toRoles:(NSString *)roles
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;


/// 发送自定义消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendCustomMessage:(NSString *)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;


/// 发送文本消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendTextMessage:(NSString *)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;



/// 发送消息确认
/// @param data 消息确认的信息体
/// @param roles 发送给的角色 默认是“agents”
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendMessageConfirmation:(id)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

/// 发送表单消息
/// @param data 消息内容
/// @param roles 发送给角色 agents/customers
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)sendFormData:(NSDictionary *)data
        toRoles:(NSString *)roles
        onSuccess:(void (^)(void))onSuccess
        onFailure:(void (^)(NSError *error))onFailure;

/// 告知对方，本地音视频已准备完成
/// @param participantId  joinRoom返回的当前用户id
/// @param user 业务层面当前用户信息
/// @param roles 发送给的角色 默认是'agents'
/// @param onSuccess 成功
/// @param onFailure 失败
-(void)readyToTalk:(NSString *)participantId
            user:(NSDictionary *)user
            toRoles:(NSString *)roles
            onSuccess:(void (^)(void))onSuccess
            onFailure:(void (^)(NSError *error))onFailure;

@end

NS_ASSUME_NONNULL_END
